$(function(){
	
	$.ajax({
		url:"/"+Udwin.appName+"/menus",
		method:"GET",
		success:function(data){
//			console.log(data);
			$(".allTypes").after(data);
		}
	})
	
	$("#menu").delegate(".allTypes","mouseover",function(){
		$("#types").width($(".allTypes").width()).css("float","left").show();
	})
	$("#menu").delegate(".allTypes","mouseout",function(){
		$("#types").hide();
	})
	
	//场景hover事件
	$("#menu").delegate("#types li","mouseover",function(){
		$("#types").width($(".allTypes").width()).css("float","left").show();
		var locationUuid=$(this).find(".obj").attr("value");
		$(".more-types").css("left",$(".allTypes").width()).data("locationUuid",locationUuid).show();
	});
	$("#menu").delegate("#types li","mouseout",function(){
		$(".more-types").hide();
		$("#types").hide();
	});
	
	//场景类型hover事件
	$("#menu").delegate(".more-types","mouseover",function(){
		$("#types").width($(".allTypes").width()).css("float","left").show();
		$(".more-types").show();
		var locationUuid = $(this).data("locationUuid");
		$("#types .obj[value="+locationUuid+"]").parent().parent().css("background-color","RGB(250,174,0)");
	});
	$("#menu").delegate(".more-types","mouseout",function(){
		var locationUuid = $(this).data("locationUuid");
		$("#types .obj[value="+locationUuid+"]").parent().parent().css("background-color","");
		$(".more-types").hide();
		$("#types").hide();
	});
	
	/**
	 * 首页 类型点击事件
	 */
	$("#menu").delegate(".more-types .list-inline li","click",function(){
		var locationUuid = $(".more-types").data("locationUuid");
		var data = {
			curPage:1,
			pageSize:9,
			locationUuid:locationUuid
		};
		
		var queryUrl = "curPage=1&pageSize=9&locationUuid="+locationUuid;
		
		var field=$(this).attr("field");
		
		if(field=="styleUuid"){
			data.styleUuid = $(this).attr("value") ;
			queryUrl += "&styleUuid="+data.styleUuid;
		}else if(field=="openUuid"){
			data.openUuid = $(this).attr("value") ;
			queryUrl += "&openUuid="+data.openUuid;
		}else if(field=="productTypeUuid"){
			data.productTypeUuid = $(this).attr("value") ;
			queryUrl += "&productTypeUuid="+data.productTypeUuid;
		}
		/*else if(field=="price"){
			data.minPrice = $(this).attr("min");
			data.maxPrice = $(this).attr("max");
			if(data.minPrice){
				queryUrl += "&minPrice="+data.minPrice;
			}
			if(data.maxPrice){
				queryUrl += "&maxPrice="+data.maxPrice;
			}
		}else if(field=="area"){
			data.minArea = $(this).attr("min");
			data.maxArea = $(this).attr("max");
			queryUrl += "&minArea="+data.minArea;
			queryUrl += "&maxArea="+data.maxArea;
		}*/
		
		window.location.href = "/"+Udwin.appName+"/product/list?"+queryUrl;
	
	});
})